<?php

namespace app\api\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule = [
        'user_name' => 'require|max:21',
        'school_name' => 'require|max:50',
        'school_address' => 'require|max:255',
        'mobile' => 'require|length:11|unique:user',
        'password' => 'require|min:6|max:32',
        'account_type' => 'require|in:1,2',
        'code' => 'require|length:4', // 验证码不能为空且必须为4位
    ];

    protected $message = [
        'user_name.require' => '用户姓名不能为空',
        'user_name.max' => '用户姓名不能超过21个字符',
        'school_name.require' => '学校名称不能为空',
        'school_name.max' => '学校名称不能超过50个字符',
        'school_address.require' => '学校地址不能为空',
        'school_address.max' => '学校地址不能超过255个字符',
        'mobile.require' => '手机号不能为空',
        'mobile.length' => '手机号必须为11位',
        'mobile.unique' => '手机号重复使用',
        'password.require' => '密码不能为空',
        'password.min' => '密码长度不能小于6位',
        'password.max' => '密码长度不能超过32位',
        'account_type.require' => '账号类型不能为空',
        'account_type.in' => '账号类型只能是1或2',
        'code.require' => '验证码不能为空', // 验证码不能为空
        'code.length' => '验证码必须为4位', // 验证码长度为4位
    ];
}
